package com.project.utility;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.project.model.RSSBBCFeed;

public class XMLHelper {
	public static String getElementValue(Node elem ) {
        Node child;
        if( elem != null){
            if (elem.hasChildNodes()){
                for( child = elem.getFirstChild(); child != null; child = child.getNextSibling() ){
                    if( child.getNodeType() == Node.TEXT_NODE  ){
                        return child.getNodeValue();
                    }
                }
            }
        }
        return "";
   }
	
	 public static String getElementValue(Document doc,String tagName){
		 NodeList list = doc.getElementsByTagName(tagName);
		 if(list.getLength()==0)
			 return "";
		 return getElementValue(list.item(0));
	   }
   
   public static String getValue(Element item, String str) {
       NodeList n = item.getElementsByTagName(str);
       return getElementValue(n.item(0));
   }
   
  
   
}
